-- since this is just an example spec, don't actually load anything here and return an empty spec
-- stylua: ignore

-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
--
-- In your plugin files, you can:
-- * add extra plugins
-- * disable/enabled LazyVim plugins
-- * override the configuration of LazyVim plugins
return {
  -- Configure LazyVim to load gruvbox
  {
    "LazyVim/LazyVim",
    opts = {
      colorscheme = "tokyonight",
    },
  },

  --{'echasnovski/mini.files'},
  { 'echasnovski/mini.icons', version = '*' },
  {
    'stevearc/oil.nvim',
    ---@module 'oil'
    ---@type oil.SetupOpts
    opts = {},
    -- Optional dependencies
    dependencies = { { "echasnovski/mini.icons", opts = {} } },
    keys = {
      { '<leader>oo', function() require('oil').open() end, desc = '[O]pen current dir' },
      { '<leader>op', function() require('oil').open(vim.fn.getcwd(-1,0)) end, desc = '[O]pen [P]arent dir' },
      { '<leader>os', function() vim.cmd.split(); require('oil').open() end, desc = '[O]pen current dir in split' },
    },
    -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
  },
  {
    'saghen/blink.cmp',
    -- optional: provides snippets for the snippet source
    dependencies = { 'rafamadriz/friendly-snippets' },

    -- use a release tag to download pre-built binaries
    version = '1.*',
    ---@module 'blink.cmp'
    ---@type blink.cmp.Config
    opts = {
        cmdline = {
          enabled = true,
          keymap = {
            -- recommended, as the default keymap will only show and select the next item
            ['<Tab>'] = { 'show', 'accept' },
          },
          completion = { menu = { auto_show = true } },
        }

    }
  },
  {
    "saghen/blink.compat",
    optional = true, -- make optional so it's only enabled if any extras need it
    opts = {},
    version = not vim.g.lazyvim_blink_main and "*",
  },
  {
    "folke/flash.nvim",
    event = "VeryLazy",
    ---@type Flash.Config
    opts = {},
    -- stylua: ignore
    keys = {
      { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
      { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
      { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
      { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
      { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
    },
  },
  -- change trouble config
  {
    "folke/trouble.nvim",
    -- opts will be merged with the parent spec
    opts = { use_diagnostic_signs = true },
  },
  { "echasnovski/mini.ai", enabled = false },
  { 'wakatime/vim-wakatime', lazy = false },
  --- for git
  {"sindrets/diffview.nvim" },
  {"tpope/vim-fugitive"},
  {
    "mikavilpas/yazi.nvim",
    enabled = false,
    event = "VeryLazy",
    keys = {
      {
        "R",
        "<cmd>Yazi<cr>",
        desc = "Open yazi at the current file",
      },
    },
    opts = {
      floating_window_scaling_factor = 1,
      yazi_floating_window_border = "none",
      open_for_directories = true,
      open_multiple_tabs = true,
      keymaps = {
        show_help = '<f1>',
        open_file_in_vertical_split = '<c-v>',
        open_file_in_horizontal_split = '<c-x>',
        open_file_in_tab = '<c-t>',
        grep_in_directory = '<c-s>',
        replace_in_directory = '<c-r>',
        cycle_open_buffers = '<tab>',
        copy_relative_path_to_selected_files = '<c-y>',
        send_to_quickfix_list = '<c-q>',
      },
    },
  },
  {'kevinhwang91/nvim-bqf'},
  {'t-troebst/perfanno.nvim'},

  -- change some telescope options and a keymap to browse plugin files
--   {
--     "telescope.nvim",
--     dependencies = {
--       {
--         "nvim-telescope/telescope-fzf-native.nvim",
--         build = "make",
--       },
--       "nvim-telescope/telescope-file-browser.nvim",
--     },
--     keys = {
--       {
--         "<leader>fP",
--         function()
--           require("telescope.builtin").find_files({
--             cwd = require("lazy.core.config").options.root,
--           })
--         end,
--         desc = "Find Plugin File",
--       },
--       {
--         ";f",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.find_files({
--             no_ignore = false,
--             hidden = true,
--           })
--         end,
--         desc = "Lists files in your current working directory, respects .gitignore",
--       },
--       {
--         ";r",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.live_grep({
--             additional_args = { "--hidden" },
--           })
--         end,
--         desc = "Search for a string in your current working directory and get results live as you type, respects .gitignore",
--       },
--       {
--         "\\\\",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.buffers()
--         end,
--         desc = "Lists open buffers",
--       },
--       {
--         ";t",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.help_tags()
--         end,
--         desc = "Lists available help tags and opens a new window with the relevant help info on <cr>",
--       },
--       {
--         ";;",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.resume()
--         end,
--         desc = "Resume the previous telescope picker",
--       },
--       {
--         ";e",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.diagnostics()
--         end,
--         desc = "Lists Diagnostics for all open buffers or a specific buffer",
--       },
--       {
--         ";s",
--         function()
--           local builtin = require("telescope.builtin")
--           builtin.treesitter()
--         end,
--         desc = "Lists Function names, variables, from Treesitter",
--       },
--       {
--         "<leader>fv",
--         function()
--           local telescope = require("telescope")
--
--           local function telescope_buffer_dir()
--             return vim.fn.expand("%:p:h")
--           end
--
--           telescope.extensions.file_browser.file_browser({
--             path = "%:p:h",
--             cwd = telescope_buffer_dir(),
--             respect_gitignore = false,
--             hidden = true,
--             grouped = true,
--             previewer = false,
--             initial_mode = "normal",
--             layout_config = { height = 40 },
--           })
--         end,
--         desc = "Open File Browser with the path of the current buffer",
--       },
--     },
--     config = function(_, opts)
--       local telescope = require("telescope")
--       local actions = require("telescope.actions")
--       local fb_actions = require("telescope").extensions.file_browser.actions
--
--       opts.defaults = vim.tbl_deep_extend("force", opts.defaults, {
--         wrap_results = true,
--         layout_strategy = "horizontal",
--         layout_config = { prompt_position = "top" },
--         sorting_strategy = "ascending",
--         winblend = 0,
--         mappings = {
--           n = {},
--         },
--       })
--       opts.pickers = {
--         diagnostics = {
--           theme = "ivy",
--           initial_mode = "normal",
--           layout_config = {
--             preview_cutoff = 9999,
--           },
--         },
--       }
--       opts.extensions = {
--         file_browser = {
--           theme = "dropdown",
--           -- disables netrw and use telescope-file-browser in its place
--           hijack_netrw = true,
--           mappings = {
--             -- your custom insert mode mappings
--             ["n"] = {
--               -- your custom normal mode mappings
--               ["N"] = fb_actions.create,
--               ["h"] = fb_actions.goto_parent_dir,
--               ["/"] = function()
--                 vim.cmd("startinsert")
--               end,
--               ["<C-u>"] = function(prompt_bufnr)
--                 for i = 1, 10 do
--                   actions.move_selection_previous(prompt_bufnr)
--                 end
--               end,
--               ["<C-d>"] = function(prompt_bufnr)
--                 for i = 1, 10 do
--                   actions.move_selection_next(prompt_bufnr)
--                 end
--               end,
--               ["<PageUp>"] = actions.preview_scrolling_up,
--               ["<PageDown>"] = actions.preview_scrolling_down,
--             },
--           },
--         },
--       }
--       telescope.setup(opts)
--       require("telescope").load_extension("fzf")
--       require("telescope").load_extension("file_browser")
--     end,
--   },

  -- add more treesitter parsers
  -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
  -- would overwrite `ensure_installed` with the new value.
  -- If you'd rather extend the default config, use the code below instead:
  {
    "nvim-treesitter/nvim-treesitter",
    opts = function(_, opts)
      -- add tsx and treesitter
      vim.list_extend(opts.ensure_installed, {
        "bash",
        "html",
        "javascript",
        "json",
        "lua",
        "markdown",
        "markdown_inline",
        "python",
        "query",
        "regex",
        "tsx",
        "typescript",
        "vim",
        "yaml",
        "rust", "ron",
        "tsx",
        "typescript",
      })
    end,
    config = function()
      require("nvim-treesitter.install").prefer_git = true
      for _, config in pairs(require("nvim-treesitter.parsers").get_parser_configs()) do
        config.install_info.url = config.install_info.url:gsub("https://github.com/", "https://githubfast.com/")
      end
    end,
  },

  -- use mini.starter instead of alpha
  -- { import = "lazyvim.plugins.extras.ui.mini-starter" },

  -- { import = "lazyvim.plugins.extras.ui.smear-cursor" },

  -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc

  -- add any tools you want to have installed below
  {
    "williamboman/mason.nvim",
    opts = {
      ensure_installed = {
        "stylua",
        "shellcheck",
        "shfmt",
        "flake8",
        "codelldb", "rust-analyzer", "taplo"
      },
      github = {
        ---@since 1.0.0
        -- The template URL to use when downloading assets from GitHub.
        -- The placeholders are the following (in order):
        -- 1. The repository (e.g. "rust-lang/rust-analyzer")
        -- 2. The release version (e.g. "v0.3.0")
        -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz")
        download_url_template = "http://ghproxy.cc/https://github.com/%s/releases/download/%s/%s",
      },
    },
  },
}
